package com.zzti.contril;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zzti.Dao.EmployeeDao;
import com.zzti.Thired.Employee;
import com.zzti.impl.EmployeeDaoimpl;

/**
 * Servlet implementation class UpdateServlet
 */
public class UpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String Emname=request.getParameter("id");
		String name=request.getParameter("name");
	String sex=request.getParameter("sex");
	int age=Integer.parseInt(request.getParameter("age"));
	String dapartment=request.getParameter("dapartment");
	String type=request.getParameter("type");
	int year=Integer.parseInt(request.getParameter("year"));


	Employee em=new Employee();
	em.setName(name);
	em.setAge(age);
	em.setSex(sex);
	em.setDapartment(dapartment);
	em.setType(type);
	em.setYear(year);
	
	//System.out.print(s);
EmployeeDao ed=new EmployeeDaoimpl();
      if(ed.UpdateEmployee(em,Emname)>0) {
    	  response.sendRedirect("EmployeeServlet");
      }
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}